<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ include file="admin_menu.jsp" %>
<%@ include file="admin_checklogin.jsp" %>
<!--/sidebar-->
<div class="main-wrap">
    <div class="crumb-wrap">
        <div class="crumb-list"><i class="icon-font"></i><a href="#">首页</a><span class="crumb-step">&gt;</span><span class="crumb-name">商品管理</span></div>
    </div>

    <div id="register" class="result-wrap">
        <form action="${pageContext.request.contextPath}/productListServlet" id="myform" method="post">
            <div class="result-title">

            </div>
            <div class="result-content">
                <table class="result-tab" width="100%">
                    <tr>

                        <th>用户ID</th>
                        <th>产品ID</th>
                        <th>评价时间</th>
                        <th>评价内容</th>
                        <th>操作</th>

                    </tr>

                    <c:forEach var="c" items="${comments.list }">
                        <tr>
                            <td>${c.user_id }</td>
                            <td>${c.product_id}</td>
                            <td>${c.comment_time}</td>
                            <td>${c.comment_content}</td>
                            <td>
<%--                                <a href="${pageContext.request.contextPath}/toUpdateProductServlet?productId=${c.comment_id}">修改</a>--%>
                                <a href="javascript:del(${c.comment_id});">删除</a>
                            </td>
                        </tr>
                    </c:forEach>

                    <script>
                        function del(id) {
                            if(confirm("你确认要删除这条评论吗")) {
                                location.href="${pageContext.request.contextPath}/delCommentServlet?commentId="+id
                            }
                        }


                    </script>

                </table>
                <c:if test="${empty plist}">
                    <div class="list-page">
                        共 ${comments.totalCount} 条记录， 当前 ${comments.currentPage}/${comments.totalPage} 页
                        <a href="${pageContext.request.contextPath}/toAllCommentListServlet?currentPage=1&row=5">首页</a>
                        <a href="${pageContext.request.contextPath}/toAllCommentListServlet?currentPage=${comments.currentPage-1<1?1:comments.currentPage-1}&row=5">上一页</a>
                        <a href="${pageContext.request.contextPath}/toAllCommentListServlet?currentPage=${comments.currentPage+1>comments.totalPage?comments.totalPage:comments.currentPage+1}&row=5">下一页</a>
                        <a href="${pageContext.request.contextPath}/toAllCommentListServlet?currentPage=${comments.totalPage}&row=5">尾页</a>
                    </div>
                </c:if>

            </div>
        </form>
    </div>
</div>
<!--/main-->
</div>
</body>
</html>